<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath() + "/";
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>朗读亭--角色菜单编辑</title>
<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<style>
.text-right {
	text-align: right;
}

tr {
	line-height: 15px;
	height: 25px;
}

.btn {
    border-radius: 3px;
    -webkit-box-shadow: none;
    box-shadow: none;
    border: 1px solid transparent;
}
.btn-primary {
    color: #fff;
    background-color: #337ab7;
    border-color: #2e6da4;
}
.btn {
    display: inline-block;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.42857143;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    -ms-touch-action: manipulation;
    touch-action: manipulation;
    cursor: pointer;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 4px;
}
.btn-success {
    color: #fff;
    background-color: #5cb85c;
    border-color: #4cae4c;
}
</style>
</head>
<body>
	<div style="width:100%;margin-top:10px;">
		<div style="width:100%;margin-top:3px;">
			<form id="typeForm">
			<input type="hidden" name="roleid" id="roleid" value="${roleid }" />
			<table  border="0">
	              <c:forEach var="menu" items="${list }">
	              <c:if test="${menu.pid==0 }">
	              	<tr>
		                <th scope="row"><input type="checkbox" class="checkbox" <c:if test="${menu.isShow=='1'}">checked="checked"</c:if> name="ids" value="${menu.id }"/>${menu.name }</th>
		                <td class="box_sle">
		                	<c:set var="a" value="0"/>
		                	<c:forEach var="menu1" items="${list }">
			                	<c:if test="${menu.id==menu1.pid }">
			                		<c:set var="a" value="${a+1}"	/>	
									<c:if test="${a%4==0 }">
										<br/>
									</c:if>	
			                     	<span><input type="checkbox" class="checkbox" <c:if test="${menu1.isShow=='1'}">checked="checked"</c:if> name="ids" value="${menu1.id }"/>${menu1.name }</span>
			                     </c:if>
		                     </c:forEach>
		                </td>
	              	</tr>
	              </c:if>
	              </c:forEach>
	         </table>
			</form>
		</div>
		<div style="text-align: center;">
			<div style="margin-top:20px;">
				<a class="btn btn-success" onclick="saveType();" >保存</a>
			</div>
		</div>
	</div>
	<script src="js/jquery-1.9.1.js"></script>
	<script type="text/javascript" src="js/layer/layer.js"></script>
	<script type="text/javascript">
		var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		function saveType(){
			$.ajax({
				async : false,
				cache : false,
				type : 'post',
				dataType : "json",
				data : $("#typeForm").serialize(),
				url : "admin/save_rolemenu",// 请求的action路径
				error : function(XMLHttpRequest, textStatus, errorThrown) {
					layer.msg("请求失败！");
				},
				success : function(data) {
					if(data.state=="9003"){
						layer.msg("没有权限！");
						return ;
					}else if(data.state=="9002"){
						layer.msg("请重新登录！");
						top.location.reload();
						return ;
					}
					if(data){
						parent.layer.close(index);
						parent.regetlist();
						layer.msg("保存成功！");
					}else{
						layer.msg("保存失败！");
					}
				}
			});	
		}
	</script>
</body>
</html>